/**
 * Copyright (C) 2006-2012 phloc systems
 * http://www.phloc.com
 * office[at]phloc[dot]com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.phloc.genericode;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.xml.transform.Result;
import javax.xml.transform.Source;

import org.genericode._2006.ns.codelist._0.CodeListDocument;
import org.genericode._2006.ns.codelist._0.CodeListSetDocument;
import org.genericode._2006.ns.codelist._0.ColumnSetDocument;
import org.w3c.dom.Document;
import org.w3c.dom.Node;

import com.phloc.commons.io.IReadableResource;
import com.phloc.commons.state.ESuccess;

/**
 * This is the DEPRECATED reader and writer for Genericode 0.4 documents.
 * 
 * @author philip
 */
@Deprecated
public class Genericode04Marshaller extends AbstractGenericodeMarshaller
{
  private static final Genericode04Marshaller s_aInstance = new Genericode04Marshaller ();

  protected Genericode04Marshaller ()
  {}

  /**
   * @return The default instance of this marshaller.
   */
  @Nonnull
  public static final Genericode04Marshaller getInstance ()
  {
    return s_aInstance;
  }

  /**
   * Read a code list from the specified source
   * 
   * @param aSource
   *        The source to be read from. May not be <code>null</code>.
   * @return <code>null</code> in case reading fails
   */
  @Nullable
  @Deprecated
  public CodeListDocument readCodeList (@Nonnull final Source aSource)
  {
    return new Genericode04CodeListMarshaller ().read (aSource);
  }

  /**
   * Read a code list using the standard marshaller.
   * 
   * @param aResource
   *        The resource to read from. May not be <code>null</code>.
   * @return <code>null</code> in case reading fails.
   */
  @Nullable
  @Deprecated
  public CodeListDocument readCodeList (@Nonnull final IReadableResource aResource)
  {
    return new Genericode04CodeListMarshaller ().read (aResource);
  }

  /**
   * Read a code list using the standard marshaller.
   * 
   * @param aNode
   *        The DOM node to read from. May not be <code>null</code>.
   * @return <code>null</code> in case reading fails.
   */
  @Nullable
  @Deprecated
  public CodeListDocument readCodeList (@Nonnull final Node aNode)
  {
    return new Genericode04CodeListMarshaller ().read (aNode);
  }

  /**
   * Read a code list set from the specified source
   * 
   * @param aSource
   *        The source to be read from. May not be <code>null</code>.
   * @return <code>null</code> in case reading fails
   */
  @Nullable
  @Deprecated
  public CodeListSetDocument readCodeListSet (@Nonnull final Source aSource)
  {
    return new Genericode04CodeListSetMarshaller ().read (aSource);
  }

  /**
   * Read a code list set using the standard marshaller.
   * 
   * @param aResource
   *        The resource to read from. May not be <code>null</code>.
   * @return <code>null</code> in case reading fails.
   */
  @Nullable
  @Deprecated
  public CodeListSetDocument readCodeListSet (@Nonnull final IReadableResource aResource)
  {
    return new Genericode04CodeListSetMarshaller ().read (aResource);
  }

  /**
   * Read a code list set using the standard marshaller.
   * 
   * @param aNode
   *        The node to read from. May not be <code>null</code>.
   * @return <code>null</code> in case reading fails.
   */
  @Nullable
  @Deprecated
  public CodeListSetDocument readCodeListSet (@Nonnull final Node aNode)
  {
    return new Genericode04CodeListSetMarshaller ().read (aNode);
  }

  /**
   * Read a column set from the specified source
   * 
   * @param aSource
   *        The source to be read from. May not be <code>null</code>.
   * @return <code>null</code> in case reading fails
   */
  @Nullable
  @Deprecated
  public ColumnSetDocument readColumnSet (@Nonnull final Source aSource)
  {
    return new Genericode04ColumnSetMarshaller ().read (aSource);
  }

  /**
   * Read a column set using the standard marshaller.
   * 
   * @param aResource
   *        The resource to read from. May not be <code>null</code>.
   * @return <code>null</code> in case reading fails.
   */
  @Nullable
  public ColumnSetDocument readColumnSet (@Nonnull final IReadableResource aResource)
  {
    return new Genericode04ColumnSetMarshaller ().read (aResource);
  }

  /**
   * Read a column set using the standard marshaller.
   * 
   * @param aNode
   *        The node to read from. May not be <code>null</code>.
   * @return <code>null</code> in case reading fails.
   */
  @Nullable
  public ColumnSetDocument readColumnSet (@Nonnull final Node aNode)
  {
    return new Genericode04ColumnSetMarshaller ().read (aNode);
  }

  /**
   * Write the code list to the desired result XML object.
   * 
   * @param aCodeList
   *        The object to be serialized to XML. May not be <code>null</code>.
   * @param aResult
   *        The result the XML should be written to. May not be
   *        <code>null</code>.
   * @return {@link ESuccess}
   */
  @Nonnull
  public ESuccess writeCodeList (@Nonnull final CodeListDocument aCodeList, @Nonnull final Result aResult)
  {
    return new Genericode04CodeListMarshaller ().write (aCodeList, aResult);
  }

  /**
   * Convert the code list to a DOM document using the standard marshaller.
   * 
   * @param aCodeList
   *        The object to be serialized to XML. May not be <code>null</code>.
   * @return <code>null</code> in case conversion fails.
   */
  @Nullable
  public Document writeCodeList (@Nonnull final CodeListDocument aCodeList)
  {
    return new Genericode04CodeListMarshaller ().write (aCodeList);
  }

  /**
   * Write the code list set to the desired result XML object.
   * 
   * @param aCodeListSet
   *        The object to be serialized to XML. May not be <code>null</code>.
   * @param aResult
   *        The result the XML should be written to. May not be
   *        <code>null</code>.
   * @return {@link ESuccess}
   */
  @Nonnull
  public ESuccess writeCodeListSet (@Nonnull final CodeListSetDocument aCodeListSet, @Nonnull final Result aResult)
  {
    return new Genericode04CodeListSetMarshaller ().write (aCodeListSet, aResult);
  }

  /**
   * Convert the code list set to a DOM document using the standard marshaller.
   * 
   * @param aCodeListSet
   *        The object to be serialized to XML. May not be <code>null</code>.
   * @return <code>null</code> in case conversion fails.
   */
  @Nullable
  public Document writeCodeListSet (@Nonnull final CodeListSetDocument aCodeListSet)
  {
    return new Genericode04CodeListSetMarshaller ().write (aCodeListSet);
  }

  /**
   * Write the column set to the desired result XML object.
   * 
   * @param aColumnSet
   *        The object to be serialized to XML. May not be <code>null</code>.
   * @param aResult
   *        The result the XML should be written to. May not be
   *        <code>null</code>.
   * @return {@link ESuccess}
   */
  @Nullable
  public ESuccess writeColumnSet (@Nonnull final ColumnSetDocument aColumnSet, @Nonnull final Result aResult)
  {
    return new Genericode04ColumnSetMarshaller ().write (aColumnSet, aResult);
  }

  /**
   * Convert the column set to a DOM document using the standard marshaller.
   * 
   * @param aColumnSet
   *        The object to be serialized to XML. May not be <code>null</code>.
   * @return <code>null</code> in case conversion fails.
   */
  @Nullable
  public Document writeColumnSet (@Nonnull final ColumnSetDocument aColumnSet)
  {
    return new Genericode04ColumnSetMarshaller ().write (aColumnSet);
  }
}
